import time

from hetong.doc_hand.index import DocHand
from hetong.db.lib_job.job_repository import get_tasks
from configs import logger


def start_task():
    while True:
        tasks = get_tasks(type=11, status=0)
        for item in tasks:
            task_id = item['id']
            file_path = item['path']
            doc_hand = DocHand(path=file_path, task_id=task_id)
            doc_hand.init_data()
            doc_hand.gen_result()
        logger.debug("本轮任务加载完成,休眠5分钟")
        time.sleep(5)

if __name__ == '__main__':
    start_task()
